<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--导入easyui样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>用户登录</title>
</head>
<script type="text/javascript">
$(function () {
	//自定义validatebox验证
	$.extend($.fn.validatebox.defaults.rules, {  
	      telphone : { //验证手机号
	    	  validator: function(value, param){ 
	    	         return /^1[3-8]+\d{9}$/.test(value);
	    	        },    
	    	        message: '请输入正确的手机号码。'
	        }
	})
	
	//配送点下拉列表
	$('#fhd').combobox({    
		url:'point_json.action',    
	    valueField:'text',    
	    textField:'text' ,
	    panelHeight:'auto',
	    editable:false
	});
	//代理点下拉列表
	$('#sjd').combobox({    
	    url:'proxy_json.action',    
	    valueField:'text',    
	    textField:'text' ,
	    panelHeight:'auto',
	    editable:false
	});
	//订单类别下拉列表
	$('#otype').combobox({    
	    url:'odertype_json.action',    
	    valueField:'text',    
	    textField:'text' ,
	    panelHeight:'auto',
	    editable:false
	});
	//物品类别下拉列表
	$('#goodstype').combobox({    
	    url:'goodstype_json.action',    
	    valueField:'text',    
	    textField:'text' ,
	    panelHeight:'auto',
	    editable:false
	});
	//日期
	$('#fhrq').datebox('setValue', getCurentDateStr());  
    $('#fhrq').datebox('calendar').calendar({  
        validator : function(date){  
            var now = new Date();  
            var d1 = new Date(now.getFullYear(),now.getMonth(),now.getDate());  
            return date >= d1;  
        }  
});  
    function getCurentDateStr()  
    {   
        var now = new Date();  
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
        var clock = year + "-";  
        if(month < 10) clock += "0";         
        clock += month + "-";  
        if(day < 10) clock += "0";   
        clock += day;  
        return clock;   
    }
	//配置提交请求
	$('#ff').form({    
	    url:'addOrder.action',    
	    success:function(data){ 
	       if(data=="1"){ 
	    	   $.messager.alert('下单成功','订单已生成，等待处理','info');
	       }else{
	    	   $.messager.show({
					title:'失败',
					msg:'下单失败，请重新填写',
					showType:'show',
					style:{
						right:'',
						top:document.body.scrollTop+document.documentElement.scrollTop,
						bottom:''
					}
				});
	       } }
	});
	//配置提交按钮
	$('#btn').linkbutton({    
		onClick:function(){
			$('#ff').submit(); 
		}   
	}); 
	//取消提交
	$('#cle').linkbutton({    
		onClick:function(){
			$("#ff").form('clear'); 
		}   
	});
	//计算价格
	$('#pic').linkbutton({    
		onClick:function(){
			var place = $("#fhd").combobox('getValue');
			var receipt = $("#sjd").combobox('getValue');
			var weight =$("#goodsweight").numberbox('getValue');
			var volume=$("#goodsvolume").numberbox('getValue');
			if(""!=place&&""!=receipt&&""!=weight&&""!=volume){	
			$.ajax({
				url:'getjiage.action',
				type:'post',
				data:{'order.place':place,'order.receipt':receipt,
					'order.weight':weight,'order.volume':volume},
				dataType:'json',
				success:function(xx){
					$("#bedisprice").val(xx.pspic);
					$("#traprice").val(xx.yspic);
					$("#tariff").numberbox('setValue',xx.pspic+xx.yspic);
				}
		})
		}else{
			$.messager.alert('计算失败','订单信息未完善，无法完成计算','info');
		}
		}
	});
	
	
})
</script>
<body>
<div>
<form id="ff" method="post">   
    <div>   
      <table  border="1">
      <tr><td>发件地</td><td>发货日期</td><td>收件地</td><td>订单类别</td><td>备注</td></tr>
      <tr><td><input id="fhd" name="order.place" required="required"></td>
      <td><input id="fhrq" name="order.fhdate" type="text" class="easyui-datebox" required="required"></td>
      <td><input id="sjd" name="order.receipt" required="required"></td>
      <td><input id="otype" name="order.type" required="required"></td>
      <td><input id="beizhu" name="order.remarks" type="text"></td></tr>

      <tr><td>寄件人姓名</td><td>寄件人联系方式</td><td>收件人姓名</td><td>收件人联系方式</td></tr>
      <tr><td><input id="sendname" name="order.sendname" type="text" class="easyui-validatebox" required="required"></td>
      <td><input id="sendtel" name="order.sendtel" type="text" class="easyui-textbox" required="required" validType="telphone"></td>
      <td><input id="adrname" name="order.addressname" type="text" class="easyui-validatebox" required="required"></td>
      <td><input id="adrtel" name="order.addresstel" type="text" class="easyui-textbox" required="required" validType="telphone"></td></tr>     
      
      <tr><td>物品类别</td><td>物品名</td><td>物品重量</td><td>物品体积</td><td><a id="pic" class="easyui-linkbutton">计算费用</a></td></tr>
      <tr><td><input id="goodstype" name="order.goodstype" required="required"></td>    
      <td><input id="goodsname" name="order.goodsname" type="text" ></td>
      <td><input id="goodsweight" name="order.weight" type="text" class="easyui-numberbox" required="required" style="width: 60px;" data-options="min:0,precision:2">千克（kg）</td>
      <td><input id="goodsvolume" name="order.volume" type="text" class="easyui-numberbox" required="required" style="width: 50px;" data-options="min:0,precision:2">立方米（m³）</td>
      <td><input id="bedisprice" name="order.bedisprice" style="display:none;"/><input id="traprice" name="order.traprice" style="display:none;"/>
      <input id="tariff" name="order.tariff" type="text"  class="easyui-numberbox" readonly="readonly" required="required" data-options="min:0,precision:2" ></td>
      </tr>
      </table><br>
		<a id="btn" style="margin-left: 230px;" class="easyui-linkbutton">提交订单</a>
		<a id="cle" style="margin-left: 250px;" class="easyui-linkbutton">取消订单</a>
    </div>         
</form> 

</div>
</body>
</html>